package net.njcp.mybatis.frame.service;

import net.njcp.mybatis.frame.builder.CustomSqlBuilder;
import org.apache.ibatis.session.SqlSessionFactory;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

/**
 * @ClassName BaseService
 * @Description: TODO
 * @Author 柳拓
 * @Date 2019/11/6
 * @Version V1.0
 **/
public interface BaseService {

    void init();

    void add(Object o);
    
    void deleteById(Class c, Serializable id);

    void delete(Class c, Map<String,Object> condition);

    void update(Object o);

    void updateBy(Object o, String fieldName, Object fieldValue);
    
    <T> T findByPrimaryKey(Class<T> c, Serializable id);
    
    <T> List<T> findAll(Class<T> c);

    <T> List<T> findBy(Class<T> c, String fieldName, String operator, Object fieldValue, String... columns);
    
    <T> List<T> findBy(Class<T> c, String fieldName, Object fieldValue);

    <T> List<T> findContent(Class<T> c, String... columns);

    <T> List<T> findContentBy(Class<T> c, String fieldName, Object fieldValue, String... content);

    <T> List<T> executeBuildSql(CustomSqlBuilder builder);

    <T> List<T> executeBuildSqlGetField(CustomSqlBuilder builder);

    SqlSessionFactory getSessionFactory();

    void setSessionFactory(SqlSessionFactory sessionFactory);

    List<Map<String, Object>> executeSql(String sql);

}
